﻿/// <reference path="jquery.js" />


$(function () {
    // 启动主页默认显示movie
    $.ajax(
    {
        type: "POST",
        url: "Home.aspx",
        data: "select_type=" + "movie",
        error: function (XMLHttpRequest, testStatus, errorThrown) {
            //alert("error");
        },
        success: function (html) {
            $("#slides").empty();
            $("#slides").append(html);
        }
    })
    // 根据输入信息检索相关电影
    $('#search').click(function () {
        var name = $("#searchContent").val();
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: { select_type: "search", message: name },
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        }
        )
    });

    $("#more").click(function () {
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: "select_type=" + "more",
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        }
        )
    });

    $("#movie").click(function () {
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: "select_type=" + "movie",
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        }
        )
    });

    $("#tv").click(function () {
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: "select_type=" + "tv",
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        }
        )
    });
    $("#cartoon").click(function () {
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: "select_type=" + "cartoon",
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        }
        )
    });
    $("#show").click(function () {
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: "select_type=" + "show",
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        }
        )
    });

    $('.type-pop').click(function ()
    {
        var type = $(".type").text();
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: { select_type: "type", message: type },
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        })
    });
    $('.region-pop').click(function ()
    {
        var region = $(".region").text();
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: { select_type: "region", message: region },
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        })
    });
    $('.year-pop').click(function ()
    {
        var year = $(".year").text();
        $.ajax(
        {
            type: "POST",
            url: "Home.aspx",
            data: { select_type: "year", message: year },
            error: function (XMLHttpRequest, testStatus, errorThrown) {
                //alert("error");
            },
            success: function (html) {
                $("#slides").empty();
                $("#slides").append(html);
            }
        })
    });
});

$(".commonMovieNormal").live("click", function ()
{
    var src_name = $(this).attr("srcName");
    var src_type = $(this).attr("srcType");
    // alert(moviename);
    $.ajax({
        type: "POST",
        url: "Detail.aspx",

        data: { name: src_name, type: src_type },
        // data:"hello"+"nihao",
        error: function (XMLHttpRequest, testStatus, errorThrown) {
            //alert("error");
        },
        success: function (html) {
            //alert("scuess");
            location.href = "Detail.aspx";
            // window.open("Detail.aspx"/*, "_self"*/);
            // $("#slides").empty();
            // $("#slides").append(html);
            // $("#slides").load("Detail.aspx")
        }
    });
});

$(".commonMovieDetail").live("click", function () {
    var src_name = $(this).attr("srcName");
    var src_type = $(this).attr("srcType");
    // alert(moviename);
    $.ajax({
        type: "POST",
        url: "Detail.aspx",

        data: { name: src_name, type: src_type },
        // data:"hello"+"nihao",
        error: function (XMLHttpRequest, testStatus, errorThrown) {
            //alert("error");
        },
        success: function (html) {
            //alert("scuess");
            location.href = "Detail.aspx";
            // window.open("Detail.aspx"/*, "_self"*/);
            // $("#slides").empty();
            // $("#slides").append(html);
            // $("#slides").load("Detail.aspx")
        }
    });
});